package top.whysu.edevice.utils;

import cn.hutool.core.date.DateUtil;
import top.whysu.edevice.constant.AppConstant;
import top.whysu.edevice.dto.app.AppRequestDTO;
import top.whysu.edevice.dto.app.AppResponseDTO;
import top.whysu.edevice.dto.generate.HeaderDTO;
import top.whysu.edevice.dto.generate.ResponseDTO;

/**
 * APP返回DTO
 */
public class AppResponseUtil {

    public static <T> AppResponseDTO<T> getSuccessResponse(AppRequestDTO requestDTO, T body) {
        final AppResponseDTO<T> response = new AppResponseDTO<>();
        response.setSeq(requestDTO.getSeq());
        response.setVersion(requestDTO.getVersion());
        response.setResult(AppConstant.Code.RESULT_CODE_SUCCESS);
        response.setMessage("操作成功");
        response.setParams(body);
        return response;
    }

    public static <T> AppResponseDTO<T> getSuccessResponse(AppRequestDTO requestDTO) {
        final AppResponseDTO<T> response = new AppResponseDTO<>();
        response.setSeq(requestDTO.getSeq());
        response.setVersion(requestDTO.getVersion());
        response.setResult(AppConstant.Code.RESULT_CODE_SUCCESS);
        response.setMessage("操作成功");
        return response;
    }


    public static <T> AppResponseDTO<T> getFailResponse(AppRequestDTO requestDTO, Integer code, String msg) {
        final AppResponseDTO<T> response = new AppResponseDTO<>();
        response.setSeq(requestDTO.getSeq());
        response.setVersion(requestDTO.getVersion());
        response.setResult(code);
        response.setMessage(msg);
        return response;
    }
}
